//gen random weights
//get optimal policy

//get new optimal policy , add to set of policies
//--run for n times--
w=rand(ws,1);
wc=zeros(ws,21);
wc(:,1)=w;
//w=[rand();rand();-rand();rand();-rand();rand()]
//ws,ns have size
pls=cell();
//pls(1).entries=br(w);
for i=1:ngen+1
    epls=gepls(i).entries;
    gsize=ggsize(i);
    grid=ggrid(i).entries;
    [s,pls(i,1).entries]=atos2(genpls2(w,1));
end

for ns=1:20
    //find j -> min u(e)-u(j)
    printf("%d\n",ns)
    u=zeros(ns,ws);
    Q=eye(ws,ws);
    C=zeros(ws,ns);
    for i=1:ngen+1
        epls=gepls(i).entries;
        gsize=ggsize(i);
        grid=ggrid(i).entries;
        vr=evalr(epls);
        for j=1:ns
            u(j,:)=evalr(pls(i,j).entries);
            C(:,j)=C(:,j)+(vr-u(j,:))';
        end
    end
    //[mn,mj]=min(vr-u);
    p=zeros(ws,1);
    b=ones(ns,1);
    xopt=qp_solve(Q,p,C,b,0);
    w=xopt;
    wc(:,ns+1)=w;
    //pls(ns+1).entries=br(w);
    for i=1:ngen+1
        epls=gepls(i).entries;
        gsize=ggsize(i);
        grid=ggrid(i).entries;
        [s,pls(i,ns+1).entries]=atos2(genpls2(w,1));
    end
end


